<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css" />
	</head>
	<body>
		<div class="wrap-container">
				<form class="layui-form" style="width: 90%;padding-top: 20px;">
					<div class="layui-form-item">
						<label class="layui-form-label">分类名称：</label>
						<div class="layui-input-block">
							<input type="text" name="clName" required   lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label">分类简介：</label>
						<div class="layui-input-block">
							<input type="text" name="clDes" required   lay-verify="required" placeholder="请输入分类简介" autocomplete="off" class="layui-input">
						</div>
					</div>


					<div class="layui-form-item">
						<label class="layui-form-label">状态：</label>
						<div class="layui-input-block">
							<input type="radio" name="clState" value="1" title="正常" checked>
							<input type="radio" name="clState" value="0" title="关闭" >
						</div>

					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="editClass">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script src="/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//Demo
			layui.use(['form','jquery'], function() {
				var form = layui.form();
				var $ = layui.jquery;
				form.render();
				//监听提交
				form.on('submit(editClass)', function(data) {
					//layer.msg(JSON.stringify(data.field));
					$.ajax({
						url:"/admin/ajax/addClass",
						type:"post",
						data:data.field,
						success:function(data){
							if(data == 1){
								layer.msg("添加分类成功！",{
									time:2000,
									end:function () {
										//先得到当前iframe层的索引
										var index = parent.layer.getFrameIndex(window.name);
										//再执行关闭
										parent.layer.close(index);
									}
								});
							}else{
								layer.msg("添加失败！");
							}
						}
					});
					return false;
				});
			});
		</script>
	</body>

</html>